﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
                    xmlns:local="clr-namespace:SQX.DataModel"
                    xmlns:dm="clr-namespace:SQX.ViewModel">
   
    <Style TargetType="{x:Type ContentControl}" x:Key="ResizablePanelStyleBottomRight">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ContentControl}">
                    <Grid DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}">
                        <Control x:Name="resizer">
                            <Control.Style>
                                <Style TargetType="{x:Type Control}">
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="{x:Type Control}">
                                                <Grid>
                                                    <local:ResizeThumb Width="7" Height="7" Cursor="SizeWE"  
                                                                       VerticalAlignment="Center" 
                                                                       HorizontalAlignment="Right"
                                                                       Margin="-50,0,0,0"/>
                                                </Grid>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </Control.Style>
                        </Control>
                        <ContentPresenter Content="{TemplateBinding Content}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type ContentControl}" x:Key="ResizablePanelStyleBottom">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ContentControl}">
                    <Grid DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}">
                        <Control x:Name="resizer">
                            <Control.Style>
                                <Style TargetType="{x:Type Control}">
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="{x:Type Control}">
                                                <Grid>
                                                    <local:ResizeThumb Width="7" Height="7" Margin="-7" Cursor="SizeNS"  
                                                                       VerticalAlignment="Bottom" HorizontalAlignment="Center"
                                                                        />
                                                </Grid>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </Control.Style>
                        </Control>
                        <ContentPresenter Content="{TemplateBinding Content}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- MDX templates-->
    <DataTemplate x:Key="memberTemplate" DataType="{x:Type dm:AdomdMember}">
        <StackPanel Orientation="Horizontal" ToolTip="{Binding ObjectCode}" 
                                    >
            <Image Source="../Resources/attribute.png" 
                                   Width="12" Height="12"
                                   Margin="0,0,10,0"/>
            <TextBlock Text="{Binding Path=ObjectName}" 
                                       FontFamily="Segoe UI" 
                                       FontSize="10"
                                       Margin="0,0,10,0"
                                       />
        </StackPanel>
    </DataTemplate>

    <HierarchicalDataTemplate x:Key="attributeTemplate" DataType="{x:Type dm:AdomdHierarchyAttribute}" ItemsSource="{Binding Members}"
                              ItemTemplate="{StaticResource memberTemplate}">
        <StackPanel Orientation="Horizontal" ToolTip="{Binding ObjectCode}" 
                                    >
            <Image Source="../Resources/attribute.png" 
                                   Width="12" Height="12"
                                   Margin="0,0,10,0"/>
            <TextBlock Text="{Binding Path=ObjectName}" 
                                       FontFamily="Segoe UI" 
                                       FontSize="10"
                                       Margin="0,0,10,0"
                                       />
        </StackPanel>
    </HierarchicalDataTemplate>

    <HierarchicalDataTemplate x:Key="hierarchyTemplate" DataType="{x:Type dm:AdomdHierarchy}" ItemsSource="{Binding Attributes}"
                              ItemTemplate="{StaticResource attributeTemplate}">
        <StackPanel Orientation="Horizontal" ToolTip="{Binding MDXPath}">
            <Image Source="../Resources/hierarchy.png" 
                                   Width="16" Height="16"
                                   Margin="0,0,10,0"/>
            <TextBlock Text="{Binding Path=ObjectName}" FontFamily="Segoe UI" FontSize="12"
                       Margin="0,0,10,0"/>
        </StackPanel>
    </HierarchicalDataTemplate>

    <HierarchicalDataTemplate x:Key="dimensionTemplate" DataType="{x:Type dm:AdomdDimension}" ItemsSource="{Binding Hierarchies}"
                              ItemTemplate="{StaticResource hierarchyTemplate}">
        <StackPanel Orientation="Horizontal" ToolTip="{Binding MDXName}">
            <Image Source="../Resources/dimension.png" 
                                   Width="18" Height="18"
                                   Margin="0,0,10,0"/>
            <TextBlock Text="{Binding Path=ObjectName}" FontFamily="Segoe UI" FontSize="12"
                       Margin="0,0,10,0"
                                       />
        </StackPanel>
    </HierarchicalDataTemplate>

    <HierarchicalDataTemplate x:Key="cubeTemplate" DataType="{x:Type dm:AdomdCube}" ItemsSource="{Binding Dimensions}"
                              ItemTemplate="{StaticResource dimensionTemplate}">
        <StackPanel Orientation="Horizontal">
            <Image Source="../Resources/olap.png" 
                                   Width="24" Height="24"
                                   Margin="0,0,10,0"/>
            <TextBlock Text="{Binding Path=ObjectName}" FontFamily="Segoe UI" FontSize="14"
                       Margin="0,0,10,0"/>
        </StackPanel>
    </HierarchicalDataTemplate>

    <HierarchicalDataTemplate x:Key="serverTemplate" DataType="{x:Type dm:AdomdServer}" ItemsSource="{Binding Cubes}"
                              ItemTemplate="{StaticResource cubeTemplate}">
            <TextBlock Text="{Binding Path=ObjectName}" FontFamily="Segoe UI" FontSize="14" FontWeight="Bold" 
                                   ToolTip="{Binding Path=ObjectName}"
                                    Margin="0,0,10,0"/>
    </HierarchicalDataTemplate>
    
    <!-- SQL templates -->
    <DataTemplate x:Key="sqlObjectTemplate" DataType="{x:Type dm:SqxObject}">
        <StackPanel Orientation="Horizontal" 
                                    >
            <Image Source="../Resources/sqlview.png" 
                                   Width="12" Height="12"
                                   Margin="0,0,10,0"/>
            <TextBlock Text="{Binding Path=ObjectName}" 
                       ToolTip="{Binding ObjectCode}"
                                       FontFamily="Segoe UI" 
                                       FontSize="10" 
                                       Margin="0,0,10,0"
                                       />
        </StackPanel>
    </DataTemplate>

    <HierarchicalDataTemplate x:Key="sqlMemberTemplate" DataType="{x:Type dm:SqxObject}" ItemsSource="{Binding Columns}" 
                              ItemTemplate="{StaticResource sqlObjectTemplate}">
        <TextBlock Text="{Binding Path=ObjectName}" FontFamily="Segoe UI" FontSize="14"
                       Margin="0,0,10,0"/>
    </HierarchicalDataTemplate>

    <HierarchicalDataTemplate x:Key="nodeTemplate" DataType="{x:Type dm:SqlDatabaseNode}" ItemsSource="{Binding SqlMembers}" 
                              ItemTemplate="{StaticResource sqlMemberTemplate}">
            <TextBlock Text="{Binding Path=ObjectName}" FontFamily="Segoe UI" FontSize="14"
                       Margin="0,0,10,0"/>
    </HierarchicalDataTemplate>

    <HierarchicalDataTemplate x:Key="sqlDBTemplate" DataType="{x:Type dm:SqlDatabase}" ItemsSource="{Binding Nodes}" 
                              ItemTemplate="{StaticResource nodeTemplate}">
        <StackPanel Orientation="Horizontal">
            <Image Source="../Resources/sqldb.png" 
                                   Width="18" Height="18"
                                   Margin="0,0,10,0"/>
            <TextBlock Text="{Binding Path=ObjectName}" FontFamily="Segoe UI" FontSize="14"
                       Margin="0,0,10,0"/>
        </StackPanel>
    </HierarchicalDataTemplate>

    <HierarchicalDataTemplate x:Key="sqlServerTemplate" DataType="{x:Type dm:SqlServer}" ItemsSource="{Binding Databases}"
                              ItemTemplate="{StaticResource sqlDBTemplate}">
        <TextBlock Text="{Binding Path=ObjectName}" FontFamily="Segoe UI" FontSize="14" FontWeight="Bold" 
                                   ToolTip="{Binding Path=ObjectName}"
                   Margin="0,0,10,0"/>
    </HierarchicalDataTemplate>

    
    
    

    


</ResourceDictionary>